﻿using HuiZe.education.Resource.Controls;
using HuiZe.education.ViewModel;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace HuiZe.education.View
{
    /// <summary>
    /// FeedbackView.xaml 的交互逻辑
    /// </summary>
    public partial class FeedbackView : UserControl
    {
        public FeedbackView()
        {
            InitializeComponent();
        }

        private void CustomButton_Click(object sender, RoutedEventArgs e)
        {
            if (images.Children.Count > 4) return;

            FeedbackViewModel model = DataContext as FeedbackViewModel;
            string fileName = model.SelectFile(2*1024);
            if (string.IsNullOrEmpty(fileName)) return;
            CustomButton customButton = new CustomButton()
            {
                Template = (ControlTemplate)FindResource("selectedImageTemplate"),
                ImageSource = new BitmapImage(new Uri(fileName)),
                Width = 70,
                Margin = new Thickness(0, 0, 10, 0),
            };

            images.Children.Add(customButton);
            model.SetImagesPath(fileName);



        }
    }
}
